/**
 * Copyright (C) 2009 aileron.cc
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package cc.aileron.orm.bind;

import java.io.IOException;
import java.util.HashMap;

import cc.aileron.commons.resource.ResourceNotFoundException;
import cc.aileron.orm.G2Dao;
import cc.aileron.orm.factory.G2DaoFactory;
import cc.aileron.template.parser.ParserMethodNotFoundException;
import cc.aileron.template.reader.TemplateSyntaxEexception;

import com.google.inject.Inject;
import com.google.inject.Singleton;

/**
 * 実装
 * 
 * @author Aileron
 */
@Singleton
public class G2BinderImpl
{
    /**
     * @param targetClass
     * @throws IOException
     * @throws ResourceNotFoundException
     * @throws TemplateSyntaxEexception
     * @throws ParserMethodNotFoundException
     */
    public void bind(final Class<?> targetClass) throws IOException,
            ResourceNotFoundException,
            TemplateSyntaxEexception,
            ParserMethodNotFoundException
    {
        final G2Dao<?> dao = factory.create(targetClass);
        daoMap.put(targetClass,
                dao);
    }

    /**
     * constractor injection
     * 
     * @param factory
     */
    @Inject
    public G2BinderImpl(final G2DaoFactory factory)
    {
        this.factory = factory;
        this.daoMap = new HashMap<Class<?>, G2Dao<?>>();
    }

    final HashMap<Class<?>, G2Dao<?>> daoMap;

    private final G2DaoFactory factory;
}
